package com.oig.sys.base.msg.impl;

import com.oig.common.constants.CommonConstants;
import com.oig.common.util.JsonUtil;
import com.oig.common.util.RequestHeaderUtil;
import com.oig.sys.base.msg.IDepMqMsgService;
import com.oig.sys.msg.api.MqMsgService;
import com.oig.sys.msg.dto.MqMsgDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class DepMqMsgServiceImpl implements IDepMqMsgService {

    private final MqMsgService mqMsgService;

    @Override
    public void addToSendMsg(String relationType, String relationId, Object obj, Integer tenantId, String tenantName) {
        MqMsgDto mqMsgDto = new MqMsgDto();
        mqMsgDto.setBusinessType(CommonConstants.DEF_MIX_STR);
        mqMsgDto.setSystemId(RequestHeaderUtil.getSystemId());
        mqMsgDto.setRelationType(relationType);
        mqMsgDto.setRelationId(relationId);
        mqMsgDto.setMsgContent(JsonUtil.toJSONString(obj));
        mqMsgDto.setTenantName(tenantName);
        mqMsgDto.setTenantId(tenantId);  //base数据不隔离所以填 0
        mqMsgService.addMqMsg(mqMsgDto);
    }


}
